<?php
/**
 * (ajax)
 */
namespace App\Admin\Ajax\Products;

use App\Models\Product\ProductSku;
use Illuminate\Support\Facades\DB;

class SkuReviewAjax{

    public function updateSkuStatus($ids){

        echo "<pre>";
        print_r($ids);
        echo "</pre>";
        exit;
        try{
            $count = 0;
            $area = [];
            $areaPskuArr = [];

            foreach ($ids as $model) {
                DB::beginTransaction();
                if($model->status == 2){
                    DB::rollBack();
                    continue;
                }
                $model->status = 2;
                $flag = $model->save();
                if(!$flag){
                    DB::rollBack();
                }else {
                    $count++;
                    DB::commit();
                }
            }

            return response()->json(['status' => true, 'message' => "成功停用{$count}条记录！"]);
        }catch (\Exception $e){
            report($e);
            return response()->json(['status' => false, 'message' => '系统异常！']);
        }
    }

}
